package org.domeos.framework.api.mapper.domeos.monitor;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.domeos.framework.api.model.monitor.ComponentStatus;
import org.domeos.framework.api.model.monitor.MonitorTarget;

/**
 * 
 * @author lixiaokai
 *
 */
@Mapper
public interface ComponentStatusMapper {
	@Insert("INSERT INTO component_status (hostname, component, status, checkTime) VALUES (" +
            "#{hostname}, #{component}, #{status}, #{checkTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
	int addCompoentStatus(ComponentStatus ComponentStatus);
	
	@Update("UPDATE component_status SET status=#{status}, checkTime=#{checkTime} WHERE hostname=#{hostname} and component=#{component}")
	int updateCompoentStatusByHostnameAndComponent(ComponentStatus ComponentStatus);

	@Select("SELECT * FROM component_status")
	List<ComponentStatus> getCompoentStatus();
	
	@Select("SELECT * FROM component_status WHERE hostname=#{hostname} and component=#{component}")
	ComponentStatus getCompoentStatusByHostnameAndComponent(ComponentStatus ComponentStatus);
}
